/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package FormController;

import Service.Balance2TransferService;
import Util.ServiceResponseObject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import th.co.tac.esv.pre.ejb.dat.balance.transfer.BalanceTransferResponse;
import th.co.tac.esv.pre.web.util.conf.LogUtil;

/**
 *
 * @author Peat
 */
public class Balance2TransferFormController extends BaseFormController {

    public Balance2TransferFormController() {
        super("Balance2TransferController.properties",
                LogUtil.BalanceTransferWebLogger,
                LogUtil.BalanceTransferWebTrnsLogger);
    }

    protected ModelAndView Balance2Transfer_Console(
            ModelAndView mv, HttpServletRequest request,
            HttpServletResponse response)
            throws Exception
    {
        Balance2TransferService service = new Balance2TransferService();
        String action = request.getParameter("action");
        BalanceTransferResponse resp = null;
        
        if (action.equals("balance2transfer")) {
            resp = service.balance2transfer(request);
        } else if (action.equals("confirm2transfer")) {
            resp = service.confirm2transfer(request);
        } else if (action.equals("result2transfer")) {
            resp = service.result2transfer(request);
        }

        if (resp!=null) {
            ServiceResponseObject sro = new ServiceResponseObject(
                    resp.getErrorStatus(),resp.getErrorCode(),
                    resp.getErrorMessage(), resp.getErrorTuxMsgSqlCode(),
                    resp.getErrorTuxMsgTextEng(), resp.getErrorTuxMsgTextThai(),
                    resp);

            mv.addObject("result", sro.toJSON().toString());
        }
        return mv;
    }
}